<?php include '../../authorization_check.php' ?>
<?php include '../../checkSecretaryOnly.php' ?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">
<title>View Course Enrollment Numbers</title>
<SCRIPT TYPE="text/javascript" src= "../../commonutils/util/util.js"> </SCRIPT>

</head>
<style type="text/css">
/* th {text-align: right} */
</style>
<body>

<?php include 'top.html' ?>


<?php
  session_start();
  $programCode = $_SESSION['programCode'];
  $semesterID = $_SESSION['semesterID'];
  $year = $_SESSION['year'];
  $semesterName = $_SESSION['semesterName'];
  
  echo " <p>You are currenttly working in <b> <font color=#00008B>".$year."-".$semesterName."</b> </font> semester.</p>";
  echo " <hr color=blue>";
    
?>

<form name=form1 method=POST action="DeletePeriod.php"> 
<?php 
require_once '../../commonutils/db/DBConnectionManager.php';
  if(isset($_POST['btnDelete'])){
  	if(isset($_POST['leaveID'])){
	  	$leaveID = $_POST['leaveID']; 
	  	$sqlquery = "delete from leaveperiod where leaveID = ".$leaveID;
		//// echo $sqlquery."<br>";
	  	$result = DBConnectionManager::query($sqlquery);
	  	echo "<p><font color=blue><b>You have successfully deleted a leave period.</b></font></p>";
		echo "<p><a href=ViewLeavePeriods.php> View leave periods. </a></p>";
  	}
  }

?>
<p>
<table border=1 cellpadding=3>
<tr>
<th>&nbsp;</th>
<th>INSTRUCTOR NAME </th>
<th>BEGIN DATE </th>
<th>END DATE </th>
</tr>
<?php

require_once '../../commonutils/db/DBConnectionManager.php';
	$sqlquery = " select lp.leaveID, concat(firstName, ' ', lastName) as iname, lp.beginDate, lp.endDate ".
				" from instructor i, leavePeriod lp ".
				" where i.instructorID = lp.instructorID and lp.semesterID = ". $semesterID ;
	 
	/* // echo $sqlquery."<br>";  */

	$result = DBConnectionManager::query($sqlquery);
	while($row = mysql_fetch_assoc($result)){
		echo "<tr>";
		echo "<td><input type=\"radio\" name=\"leaveID\" value= \"".$row['leaveID']."\"></td>";
		echo "<td>".$row['iname']." &nbsp;</td>";
		echo "<td>".$row['beginDate']." &nbsp;</td>";
		echo "<td>".$row['endDate']."     &nbsp;</td>";

		echo "</tr>";		
	}
	
	

?>

</table>
</form>

<p>
  <input type=submit value=" Delete " name=btnDelete size=10 onClick="return radioControl(leaveID)"/> &nbsp;
  <input type=reset value=" Clear selection " name=btnReset size=10 /> &nbsp;
</p>

<?php include 'bottom.php' ?>

</body>


</html>